import Loading from "./Loading.vue";
import Vue from "vue";

//获取loading 组件的构造函数,构造loading组件
const LoadingConstructor = Vue.extend(Loading);

const serve = ()=>{
    //创建loading 实例
    let loadingInstance = new LoadingConstructor();
    //将组件挂载到指定的元素
    loadingInstance.$mount(document.createElement('div'))
    //将组件挂载的元素添加到body元素下
    document.body.appendChild(loadingInstance.$el);

    Vue.nextTick(()=>{
        loadingInstance.visible =true;

        setTimeout(()=>{
            loadingInstance.visible =false;
        },2000);
    })
    return loadingInstance;
}

export default serve;
